package com.li.springbootproject.utils;

import javax.annotation.PostConstruct;

import com.lidong.toolkit.constant.LogConst;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2/21/2022 9:11 PM
 */
@Component
public class ApplicationContextUtils {

    private static final Logger logger = LoggerFactory.getLogger(ApplicationContextUtils.class);

    public static ApplicationContext applicationContext;

    @Autowired
    private ApplicationContext applicationContextBean;

    @PostConstruct
    public void init() {
        logger.info(LogConst.LOG_SUCCESS_PREFIX+"ApplicationContextUtils Registered... ");
        ApplicationContextUtils.applicationContext = applicationContextBean;
    }

}
